<template>
  <div>
    <GlobalArticle
        v-for="(blogItem, index) of blogList"
        :article-data="blogItem"
        :key="index"
    ></GlobalArticle>
    <el-pagination
        layout="prev, pager, next"
        :page-size="params.limit"
        :total="totalNum"
        @current-change="changePage"
    >
    </el-pagination>
  </div>
</template>

<script>
import GlobalArticle from "@/components/Global-Article"
import BlogService from '@/service/blogService'
export default {
  name: "MyBlog",
  components:{
    GlobalArticle
  },
  data() {
    return {
      blogList: [],
      params: {
        limit: 1,// 每页的数量
        offset: 0//偏移量
      },
      totalNum: 0
    }
  },
  created() {

    this.getMyBlogData()
  },
  methods: {
    getMyBlogData() {
      BlogService.getMyBlog(this.params).then(rs => {
        this.totalNum = rs.data.data.totalNum;
        this.blogList = rs.data.data.blogList;

      })
    },
    changePage(page){
      this.params.offset = (page-1) * this.params.limit;
      this.getMyBlogData();
    }
  }
}
</script>

<style scoped>

</style>